\rcube_string_replacer

Helper class for string replacements based on preg_replace_callback

Summary

Methods
Properties
Constants
__construct()
add()
get_replacement()
replace()
resolve()
$pattern
$mailto_pattern
$link_pattern
$linkref_index
$linkref_pattern
No constants found
link_callback()
linkref_addindex()
linkref_callback()
mailto_callback()
replace_callback()
parse_url_brackets()
$values
$options
$linkrefs
$urls
$noword
N/A
No private methods found
No private properties found
N/A

Properties

$pattern

$pattern

$mailto_pattern

$mailto_pattern

$link_pattern

$link_pattern

$linkref_index

$linkref_index

$linkref_pattern

$linkref_pattern

$values

$values

$options

$options

$linkrefs

$linkrefs

$urls

$urls

$noword

$noword

Methods

__construct()

__construct(array  $options = []) : mixed

Object constructor

Parameters

array $options

Configuration options

Returns

mixed —

add()

add(string  $str) : int

Add a string to the internal list

Parameters

string $str

String value

Returns

int —

Index of value for retrieval

get_replacement()

get_replacement(string|int  $i) : string

Build replacement string

Parameters

string|int $i

Replacement index

Returns

string —

Replacement string

replace()

replace(string  $str) : string

Replace all defined (link|mailto) patterns with replacement string

Parameters

string $str

Text

Returns

string —

Text

resolve()

resolve(string  $str) : string

Replace substituted strings with original values

Parameters

string $str

Text

Returns

string —

Text

link_callback()

link_callback(array  $matches) : string

Callback function used to build HTML links around URL strings

Parameters

array $matches

Matches result from preg_replace_callback

Returns

string —

Return valid link for recognized schemes, otherwise return the unmodified URL.

linkref_addindex()

linkref_addindex(array  $matches) : string

Callback to add an entry to the link index

Parameters

array $matches

Matches result from preg_replace_callback with PREG_OFFSET_CAPTURE

Returns

string —

Replacement string

linkref_callback()

linkref_callback(array  $matches) : string

Callback to replace link references with real links

Parameters

array $matches

Matches result from preg_replace_callback with PREG_OFFSET_CAPTURE

Returns

string —

Replacement string

mailto_callback()

mailto_callback(array  $matches) : string

Callback function used to build mailto: links around e-mail strings

Parameters

array $matches

Matches result from preg_replace_callback

Returns

string —

Replacement string

replace_callback()

replace_callback(array  $matches) : string

Look up the index from the preg_replace matches array and return the substitution value.

Parameters

array $matches

Matches result from preg_replace_callback

Returns

string —

Value at index $matches[1]

parse_url_brackets()

parse_url_brackets(string  $url) : string

Fixes bracket characters in URL handling

Parameters

string $url

URL

Returns

string —

Suffix (the rest of the URL input)